<!doctype html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml" xmlns:v-model="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="../../vender/animate@3.5.0.min.css">
</head>
<body>

<div id="app">

    <my-component></my-component>
</div>


</body>
<script src="../../vender/vue@2.4.2.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/velocity/1.2.3/velocity.min.js"></script>

<script>
    var app=new Vue({
        el:'#app',
        components:{
            myComponent:{
                template:`<div>
                    <button @click="toggle()">Toggle</button>
                    <transition
                        <button :key="state">{{msg}}</button>
                    </transition>
                </div>`,
                data: function () {
                    return {
                        state:'saved'
                    }
                },
                methods:{
                    toggle: function () {
                        var idx=0;
                        return function () {
                            var st=['saved','edited','editing'][idx++%3];
                            console.log('state:',st);
                            this.state=st;
                        }
                    }()
                },
                computed:{
                    msg: function () {
                        switch(this.state){
                            case 'saved':return 'Edit';
                            case 'edited':return 'Save';
                            case 'editing':return 'Cancel';
                        }
                    }
                }
            }
        }
    });



</script>
</html>